package multithread.framework.threadmethod;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
/**
 * cache for many test case
 * @author dailey_dai
 *
 */
public class TestCaseContainer implements IContainer {
	private static class InnerSingleton {
		private static final TestCaseContainer instance = new TestCaseContainer();
	}

	public static TestCaseContainer getInstance() {
		return InnerSingleton.instance;
	}

	public static TestCaseContainer newInsatnce() {
		return new TestCaseContainer();
	}

	private List<ThreadMethodContainer> testcaseList = null;

	private TestCaseContainer() {
		testcaseList = new LinkedList<ThreadMethodContainer>();
	}

	/**
	 * add ThreadMethodContainer, allow duplicate
	 * @param container ThreadMethodContainer
	 * @return boolean
	 */
	public boolean addThreadMethodContainer(ThreadMethodContainer container) {
		// if (!testcaseList.contains(container)) {
		return testcaseList.add(container);
		// }
		// return false;
	}

	public boolean isEmpty() {
		return testcaseList.isEmpty();
	}

	public Iterator<ThreadMethodContainer> iterator() {
		return testcaseList.iterator();
	}

}
